<template>
	<view class="page">
		<!-- <view class="flex benben-position-layout flex flex-wrap align-center testExamination_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub testExamination_fd0_0'>
				<view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  testExamination_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<text class='testExamination_fd0_0_c1'>身份证</text>
				<view class='flex flex-wrap align-center testExamination_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view> -->
		
		<view class="content_view">
			<view class="content_title">证件图片</view>
			<view class="cards">
				<view class="cards_item">
					<view class="cards_item_img" @tap.stop="uploadImg(1)">
						<template v-if="!id_card_front">
							<image mode="aspectFill" :src='STATIC_URL+"253.png"'></image>
							<image class="add_icon" mode="aspectFill" :src='STATIC_URL+"255.png"'></image>
						</template>
						<template v-else>
							<image mode="aspectFill" :src='id_card_front'></image>
						</template>
					</view>
					<view class="cards_item_tip">上传身份证人像面</view>
				</view>
				<view class="cards_item">
					<view class="cards_item_img" @tap.stop="uploadImg(2)">
						<template v-if="!id_card_back">
							<image mode="aspectFill" :src='STATIC_URL+"254.png"'></image>
							<image class="add_icon" mode="aspectFill" :src='STATIC_URL+"255.png"'></image>
						</template>
						<template v-else>
							<image mode="aspectFill" :src='id_card_back'></image>
						</template>
						
					</view>
					<view class="cards_item_tip">上传身份证国徽面</view>
				</view>
			</view>
		</view>
		<view class="content_view" style="padding-bottom: 0;">
			<view class="content_title">证件信息</view>
			<view class='flex flex-wrap align-center justify-between personalInformation_fd1_0'>
				<text class='personalInformation_fd1_0_c0'>姓名</text>
				<input class='flex-sub personalInformation_fd1_1_c1' type="text" placeholder="请输入" confirm-type="done" :maxlength="14" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx"
				:disabled="true" v-model="name" />
			</view>
			<view class='flex flex-wrap align-center justify-between personalInformation_fd1_0'>
				<text class='personalInformation_fd1_0_c0'>性别</text>
				<view class="sex_content">
					<view class="sex_item">
						<image v-if="sex == '男'" mode="aspectFill" :src='STATIC_URL+"7.png"'></image>
						<image v-else mode="aspectFill" :src='STATIC_URL+"8.png"'></image>
						<text>男</text>
					</view>
					<view class="sex_item">
						<image v-if="sex == '女'" mode="aspectFill" :src='STATIC_URL+"7.png"'></image>
						<image v-else mode="aspectFill" :src='STATIC_URL+"8.png"'></image>
						<text>女</text>
					</view>
				</view>
			</view>
			<view class='flex flex-wrap align-center justify-between personalInformation_fd1_0'>
				<text class='personalInformation_fd1_0_c0'>身份证号</text>
				<input class='flex-sub personalInformation_fd1_1_c1' type="text" placeholder="请输入" confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx" :disabled="true" v-model="id_no" />
			</view>
			<view class='flex flex-wrap align-center justify-between personalInformation_fd1_0'>
				<text class='personalInformation_fd1_0_c0'>发证机关</text>
				<input class='flex-sub personalInformation_fd1_1_c1' type="text" placeholder="请输入" confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx"
				:disabled="true" v-model="authority" />
			</view>
			<view class='flex flex-wrap align-center justify-between personalInformation_fd1_0'>
				<text class='personalInformation_fd1_0_c0'>有效期</text>
				<input class='flex-sub personalInformation_fd1_1_c1' type="text" placeholder="开始时间-结束时间" confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx" :disabled="true" v-model="period" />
			</view>
		</view>
		
		<view class="flex align-center justify-between feedback_flex_4" @tap.stop="saveContact">
			<view class='feedback_fd4_0'>提交</view>
		</view>
		
		<u-modal v-model="show" content="检测到已经存在相同身份证号的用户,已合并用户数据" confirm-color="#FC5B03" @confirm="isBack"></u-modal>
		
		<u-modal v-model="errShow" title="提示" :mask-close-able="true" :content="errContent" confirm-color="#FC5B03"></u-modal>
	</view>
</template>
<script>
	export default {
		components: {},

		data() {
			return {
				sex: "",
				name: "",
				id_no: "",
				id_card_front: "",  // 身份证正面
				id_card_back: "",   // 身份证反面
				authority: "",  // 发证机关
				period: "",  // 有效期
				is_submit: false,
				show: false,
				errShow: false,
				errContent: '',
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 图片上传
			uploadImg(type) {
				let _this = this;
				uni.chooseImage({
					count: 1,
					sourceType: ['album', 'camera'],
					success: (chooseImageRes) => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
						uni.showLoading({
							title: '识别中'
						})
						uni.uploadFile({
							url: global.BASE_URL + global.apiUrls.postUpload, //仅为示例，非真实的接口地址
							filePath: tempFilePaths[0],
							name: 'image',
							formData: {
								image: 'image',
								type: type,
								source: 1,
								user_id: global.userInfo.user_id,
								// user_id: 3
							},
							success: (uploadFileRes) => {
								uni.hideLoading();
								let result = JSON.parse(uploadFileRes.data);
								// console.log(result);
								if (type == 1) {
									if (result.code == 1) {
										if (result.data.auth.pass == 1) {
											_this.id_card_front = result.data.data.file_url;
											_this.name = result.data.card_info.name;
											_this.sex = result.data.card_info.sex;
											_this.id_no = result.data.card_info.idCard_no;
											if (result.data.auth.has_repeat == 1) {
												_this.show = true;
												uni.$emit('save');
											}
										} else {
											_this.$message.info(result.data.auth.msg);
										}
									} else {
										_this.errContent = result.info;
										_this.errShow = true;
									}
								} else if (type == 2) {
									if (result.code == 1) {
										if (result.data.auth.pass == 1) {
											_this.id_card_back = result.data.data.file_url;
											_this.authority = result.data.card_info.sign_body;
											_this.period = result.data.card_info.sign_date + ' - ' + result.data.card_info.end_date;
										} else {
											_this.$message.info(result.data.auth.msg);
										}
									} else {
										_this.errContent = result.info;
										_this.errShow = true;
									}
								}
							},
							fail: (err) => {
								console.log(err);
								uni.hideLoading();
								_this.$message.info('图片上传失败，请重试');
							}
						});
					}
				});
			},
			// 保存身份证信息
			saveContact() {
				if (!this.id_card_front) {
					this.$message.info('请上传身份证人像面照片');
					return false;
				}
				if (!this.id_card_back) {
					this.$message.info('请上传身份证国徽面照片');
					return false;
				}
				this.$message.info('提交成功');
				setTimeout(() => {
					uni.$emit('save');
					uni.navigateBack();
				}, 800)
			},
			// 合并身份证号重复的用户  mergeUser
			postMergeUser() {
				this.$api.post(global.apiUrls.mergeUser, {
					
				}).then(res => {
					this.$message.info(res.data.info);
				})
			},
			isBack() {
				uni.navigateBack();
			}
		}
	};
</script>
<style lang="scss" scoped>
	.sex_content {
		display: flex;
		align-items: center;
		.sex_item {
			display: flex;
			align-items: center;
			margin-left: 30rpx;
			image {
				width: 32rpx;
				height: 32rpx;
				margin-right: 10rpx;
			}
			text {
				font-weight: 500;
				font-size: 28rpx;
				color: rgba(0,0,0,0.8);
			}
		}
	}
	.content_view {
		background: #fff;
		border-radius: 16rpx;
		padding: 30rpx 24rpx 28rpx;
		margin: 20rpx 24rpx;
		.cards {
			display: flex;
			align-items: center;
			justify-content: space-between;
			.cards_item {
				.cards_item_img {
					width: 320rpx;
					height: 168rpx;
					position: relative;
					image {
						width: 100%;
						height: 100%;
						border-radius: 8rpx;
					}
					.add_icon {
						width: 74rpx;
						height: 74rpx;
						position: absolute;
						top: 50%;
						left: 50%;
						transform: translate(-50%, -50%);
					}
				}
				.cards_item_tip {
					text-align: center;
					font-weight: 400;
					font-size: 24rpx;
					color: #222222;
					margin-top: 20rpx;
				}
			}
		}
	}
	.content_title {
		font-weight: 500;
		font-size: 30rpx;
		color: #222222;
		margin-bottom: 24rpx;
	}
	
	.personalInformation_fd1_0 {
		padding: 28rpx 0;
		border-top: 2rpx solid #eee;
	}
	
	.personalInformation_fd1_0_c0 {
		font-size: 28rpx;
		color: rgba(0,0,0,0.6);
	}
	.personalInformation_fd1_1_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: #111;
		text-align: right;
	}
	
	
	.feedback_fd4_0 {
		width: 640rpx;
		border-radius: 80rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #fff;
		margin: 0rpx 32rpx 0rpx 32rpx;
		height: 84rpx;
		line-height: 84rpx;
		text-align: center;
		background: #FC5B03;
	}
	
	.feedback_flex_4 {
		width: 750rpx;
		height: 120rpx;
		overflow: hidden;
		position: fixed;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		display: flex;
		justify-content: center;
		background: #fff;
	}
	
	
	
	
	.testExamination_fd1_0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		padding: 40rpx 32rpx 24rpx 32rpx;
	}

	.testExamination_fd1_0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_fd1_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #333333;
	}

	.testExamination_notAnfd1_1_c0 {
		background: rgba(244, 250, 255, 1);
		background-size: 100% !important;
		width: 750rpx;
		height: 80rpx;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.testExamination_anfd1_1_c0 {
		background: rgba(244, 250, 255, 1);
		background-size: 100% !important;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
		width: 750rpx;
		height: 80rpx;
	}

	.testExamination_areafd1_1_c0 {
		min-height: 80rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.testExamination_notAnfd1_1_c0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_notAnfd1_1_c0_c0_c1 {
		margin: 0rpx 20rpx 0rpx 0rpx;
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #1593FF;
	}

	.testExamination_notAnfd1_1_c0_c0_c2 {
		font-weight: 700;
		font-size: 32rpx;
		color: #1593FF;
		line-height: 45rpx;
		text-decoration: none;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.testExamination_anfd1_1_c0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_anfd1_1_c0_c0_c1 {
		margin: 0rpx 20rpx 0rpx 0rpx;
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #1593FF;
	}

	.testExamination_anfd1_1_c0_c0_c2 {
		font-weight: 700;
		font-size: 32rpx;
		color: #1593FF;
		line-height: 45rpx;
		text-decoration: none;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.testExamination_areafd1_1_c0_c0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 40rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0_c0 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 15rpx 0rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0_c1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c0 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(21, 147, 255, 1);
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c3 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 32rpx 0rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c4 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c5 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c1 {
		font-size: 26rpx;
		color: rgba(191, 191, 191, 1);
	}

	.testExamination_areafd1_1_c0_c0_c1 {
		background: rgba(242, 242, 242, 1);
		background-size: 100% !important;
		width: 602rpx;
		height: 16rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		background-size: 100% auto !important;
	}

	.testExamination_progress1_areafd1_1_c0_c0_c1 {
		background: rgba(21, 147, 255, 1);
		background-size: 100% !important;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}

	.testExamination_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.testExamination_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #111;
	}

	.testExamination_fd0_0_c1 {
		font-size: 32rpx;
		font-weight: bold;
		color: #111111;
	}

	.testExamination_fd0_0_c2 {
		width: 36rpx;
		height: 36rpx;
	}

	.testExamination_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.page {
		min-height: calc(100vh - var(--window-bottom));
		background: #f6f7fb;
		background-size: 100% auto !important;
	}
</style>